<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="账单日期">
              <j-date class="query-group-cust" v-model="queryParam.date_begin" placeholder="请选择开始日期"/>
              <span class="query-group-split-cust"></span>
              <j-date class="query-group-cust" v-model="queryParam.date_end" placeholder="请选择结束日期"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="对公账号">
              <a-input v-model="queryParam.accountNo" placeholder="请输入对公账号"/>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
            <!--              <a-form-item label="本次查询的汇总金额(单位元)">-->
            <!--            <a-input class="query-group-cust" v-model="queryParam.money_begin" placeholder="请输入最开始值"/>-->
            <!--            <span class="query-group-split-cust"></span>-->
            <!--            <a-input class="query-group-cust" v-model="queryParam.money_end" placeholder="请输入最结束值"/>-->
            <!--          </a-form-item>-->
            <!--        </a-col>-->
            <!--          <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
            <!--            <a-form-item label="返回查询的结果条数">-->
            <!--          <a-input v-model="queryParam.count" placeholder="请输入返回查询的结果条数"/>-->
            <!--        </a-form-item>-->
            <!--      </a-col>-->

            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="对方名称">
                <a-input v-model="queryParam.otherName" placeholder="请输入对方名称"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="对方账号">
                <a-input v-model="queryParam.otherAccAo" placeholder="请输入对方账号"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="对方行号">
                <a-input v-model="queryParam.otherOpenNo" placeholder="请输入对方行号"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24" v-is-group>
              <a-form-item label="所属公司">
                <j-company-select-tag placeholder="请选择所属公司" v-model="queryParam.companyId"/>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span class="table-page-search-submitButtons table-operator">
              <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
              <a-button type="primary" icon="reload" @click="searchReset">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                <span>{{ toggleSearchStatus ? '收起' : '展开' }}</span>
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
<!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
      <a-button type="primary" icon="download" v-has="'publicAccount:export'" @click="handleExportXls('对公账户交易明细记录详情')">导出</a-button>
      <a-button type="primary" v-is-group v-has="'publicAccount:download'" icon="download" @click="publicAccountOperation()">下载对账单
      </a-button>
<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
      <a-dropdown v-has="'publicAccount:delete'" v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
<!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
<!--        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项-->
<!--        <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
<!--      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{  x: 2000, y: screenHeight }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-wrap"
        @change="handleTableChange">

<!--        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"-->

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <publicAccountTransactionInquiryDetails-modal ref="modalForm" @ok="modalFormOk"></publicAccountTransactionInquiryDetails-modal>
    <publicAccountTransactionInquiryDetailsOperation-modal ref="operationForm" @ok="modalFormOk"></publicAccountTransactionInquiryDetailsOperation-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import PublicAccountTransactionInquiryDetailsModal from './modules/PublicAccountTransactionInquiryDetailsModal'
  import PublicAccountTransactionInquiryDetailsOperationModal from './modules/PublicAccountTransactionInquiryDetailsOperationModal'
  import JCompanySelectTag from '@comp/jeecg/JCompanySelectTag'
  import JDate from '@comp/jeecg/JDate'

  export default {
    name: "PublicAccountTransactionInquiryDetailsList",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      JCompanySelectTag,
      JDate,
      PublicAccountTransactionInquiryDetailsOperationModal,
      PublicAccountTransactionInquiryDetailsModal
    },
    data () {
      return {
        description: '对公账户交易明细记录详情管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            fixed: 'left',
            align: 'center',
            customRender: (text, record, index) =>
              `${(this.ipagination.current - 1) * this.ipagination.pageSize + index + 1}`
          },
          {
            title:'账单日期',
            align:"center",
            dataIndex: 'date',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'交易时间日期',
            align:"center",
            dataIndex: 'tradeDateTime',
            // customRender:function (text) {
            //   return !text?"":(text.length>10?text.substr(0,10):text)
            // }
          },
          {
            title:'交易流水',
            align:"center",
            dataIndex: 'tradeNo'
          },
          {
            title:'对公账号',
            align:"center",
            dataIndex: 'accountNo'
          },
          {
            title:'对方名称',
            align:"center",
            dataIndex: 'otherName'
          },
          {
            title:'对方账号',
            align:"center",
            dataIndex: 'otherAccAo'
          },
          {
            title:'对方行号',
            align:"center",
            dataIndex: 'otherOpenNo'
          },
          {
            title:'金额',
            align:"center",
            dataIndex: 'tranAmt',
            customRender: function (text) {
              if (!text) {
                text = 0
              }
              return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
            }
          },
          {
            title:'摘要',
            align:"center",
            dataIndex: 'memo'
          },
          {
            title:'交易类型',
            align:"center",
            dataIndex: 'drcrFlag'
          },
          {
            title:'余额',
            align:"center",
            dataIndex: 'accBal',
            customRender: function (text) {
              if (!text) {
                text = 0
              }
              return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
            }
          },
        ],
        url: {
          list: "/zcgl/publicAccountTransactionInquiryDetails/list",
          delete: "/zcgl/publicAccountTransactionInquiryDetails/delete",
          deleteBatch: "/zcgl/publicAccountTransactionInquiryDetails/deleteBatch",
          exportXlsUrl: "/zcgl/publicAccountTransactionInquiryDetails/exportXls",
          importExcelUrl: "zcgl/publicAccountTransactionInquiryDetails/importExcel",
        },
        dictOptions:{},
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
        this.addColumns()
      },
      publicAccountOperation () {
        this.$refs.operationForm.show()
      },

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>